package com.demo.design.factory;


import lombok.extern.slf4j.Slf4j;

/**
 * 抽象工厂、超级工厂
 * @author Administrator
 */
@Slf4j
public class AbstractFactory {

    public static void main(String[] args) {
        new FactoryProducer().getFactory(50).getStudent("a").nextJob();
        new FactoryProducer().getFactory(200).getWorker("a").work();
    }

}
interface BaseWorker {
    void work();
}
@Slf4j
class Worker1 implements BaseWorker {
    @Override
    public void work() {
        log.info("I will go to work;");
    }
}
@Slf4j
class Worker2 implements BaseWorker {
    @Override
    public void work() {
        log.info("I will  go to sleep;");
    }
}
interface  BaseStudent{
    void nextJob();
}
@Slf4j
class Stundet1 implements BaseStudent{
    @Override
    public void nextJob() {
        log.info("dinner--------------");
    }
}
@Slf4j
class Stundet2 implements BaseStudent{
    @Override
    public void nextJob() {
        log.info("sleep--------------");
    }
}
abstract class   SuperFactory{
    abstract  BaseWorker getWorker(String type);
    abstract  BaseStudent getStudent(String time);
}
class WorkerFactory extends SuperFactory{
    @Override
    BaseWorker getWorker(String type) {
        switch (type) {
            case "b":
                return new Worker1();
            default:
                return new Worker2();
        }
    }

    @Override
    BaseStudent getStudent(String time) {
        return null;
    }
}
class StudentFactory extends  SuperFactory{
    @Override
    BaseWorker getWorker(String type) {
        return null;
    }
    @Override
    BaseStudent getStudent(String time) {
        switch (time) {
            case "a":
                return new Stundet1();
            default:
                return new Stundet2();
        }
    }

}
class FactoryProducer{
    public  SuperFactory getFactory(Integer age){
        if(age>100){
            return new WorkerFactory();
        }else{
            return new StudentFactory();
        }
    }
}
